﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LGCourt.Logic.BLL;
using LGCourt.Logic.NBL.DBEntities;
using lgweb.common;

namespace lgweb.inside.learning
{
    public partial class detail : NeedValidatePage
    {
        private int _aid = 1;
        public string _cate = "7";
        private string _cateName = "专题研究";
        protected void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);
            if (!this.IsPostBack)
            {
                GetParam();
                GetInfo();
            }
        }


        private void GetParam()
        {
            this._cate = string.IsNullOrEmpty(Request.QueryString["cate"]) ? "7" : Request.QueryString["cate"];           
            this.spBaoCate.HRef = "/inside/learning/list.aspx?cate=" + this._cate;
            this._aid = string.IsNullOrEmpty(Request.QueryString["id"]) ? 1 : Convert.ToInt32(Request.QueryString["id"]);
        }

        private void GetInfo()
        {
            ColInfo bll = new ColInfo();
            DeptClassCondition classParam = new DeptClassCondition();
            classParam.Name = "首页栏目";
            List<V_DICT_SOURCE> classInfoList = bll.GetDeptSourceList(classParam);
            if (classInfoList.Count >= int.Parse(_cate))
            {
                V_DICT_SOURCE classInfo = classInfoList[int.Parse(_cate) - 1];
                this.spBaoCate.InnerHtml = classInfo.Source;
            }
            //BBS bll = new BBS();
            //InfoCondition param = new InfoCondition();
            //param.aid = this._aid;

            //vPortalArticleTitleEx result = (vPortalArticleTitleEx)bll.GetInfo(param);
            QueryCondition param = new QueryCondition();
            param.id = this._aid;
            LGFY_Platform_Articles result = (LGFY_Platform_Articles)bll.GetNewsInfo(param);
            if (result != null)
            {
                this.author.InnerHtml = result.Publishers;
                this.title.InnerHtml = result.Title;
                this.InfoFrom.InnerHtml = result.Comefrom;
                this.content.InnerHtml = result.Text;
                this.viewCount.InnerHtml = result.Hit.GetValueOrDefault(0).ToString();
                this.dtime.InnerHtml = result.PubDate.ToString();

            }
        }
    }
}